<?php
class Auth extends Config
{
	var $page;
	var $allFields;
	var $tableName = "users";
	var $errors;
	
	function check($login, $pass, $uniQuery = null)
	{
		$login = mysql_real_escape_string($login);
		$pass = md5(md5($pass));
		
		$queryText = "SELECT * FROM `". $this -> DB_PREFIX . $this -> tableName ."` WHERE `name` = '" .$login ."' AND `pass` = '". $pass ."' ". $uniQuery;
		$query = $this -> sql($queryText);
		if (mysql_num_rows($query) != 0)
		{
			$data = mysql_fetch_array($query);
			$_SESSION['id'] = $data['id'];
			$_SESSION['login'] = $data['login'];
			return true;
		}
		else
		{
			$this -> errors = "Пользователя с таким логином и паролем не существует!";
			return false;
		}
	}
	
	function getState()
	{
		
	}
	
}
?>